#include <iostream>
#include <string>
#include <vector>

using namespace std;
/*
类模板
vector()：									默认构造函数，创建空的 vector。
vector(size_type count)：					创建指定大小的 vector。
vector(size_type count, const T &value)：	创建指定大小并填充指定值的 vector。
vector(const vector &other)：				拷贝构造函数。
*/

typedef struct book
{
    string name;
    int id;
} book;

book book_data[10] = {
    {.name = "《母猪产后护理》", .id = 1},
    {.name = "《关于找对象的101种技巧》", .id = 2},
    {.name = "《富婆通讯录》", .id = 3},
    {.name = "《霸道总裁爱上我》", .id = 4},
    {.name = "《如何一夜暴富》", .id = 5},
    {.name = "《郑迎佳自传》", .id = 6},
    {.name = "《葵花宝典&辟邪剑谱修炼心得》", .id = 7}};

int main(int argc, char const *argv[])
{

    // 实现空构造
    vector<book> book_list_1;

    book_list_1.push_back(book_data[0]);
    book_list_1.push_back(book_data[1]);

    cout << "============================================================" << endl;

    // 遍历
    for (auto it = book_list_1.begin(); it != book_list_1.end(); it++)
    {
        book book_temp = *it;
        cout << "书名:" << book_temp.name << endl;
        cout << "编号:" << book_temp.id << endl;
    }

    cout << "============================================================" << endl;

    vector<book> book_list_2(20);

    cout << "book_list_2 的容量大小" << book_list_2.size() << endl;
    cout << "book_list_2 的最大空间" << book_list_2.max_size() << endl;

    cout << "book_list_2 中是否有数据" << book_list_2.empty() << endl;

    vector<book> book_list_3(20, book_data[0]);
    // 遍历
    for (auto it = book_list_3.begin(); it != book_list_3.end(); it++)
    {
        book book_temp = *it;
        cout << "书名:" << book_temp.name << endl;
        cout << "编号:" << book_temp.id << endl;
    }

    vector<book> book_list_4(book_list_1);
    // 遍历
    for (auto it = book_list_4.begin(); it != book_list_4.end(); it++)
    {
        book book_temp = *it;
        cout << "书名:" << book_temp.name << endl;
        cout << "编号:" << book_temp.id << endl;
    }

    return 0;
}